﻿@model Sharp.Web.Models.UserGroupIndexModel
@{
    var x = Html.X();
}



@(
        x.GridPanel()
            .TopBar(x.Toolbar().Items(
                x.Button().Text("浏览").Icon(Icon.ApplicationForm).OnClientClick("App.Grid.OnModuleOperation(this,'" + Url.Action("Details") + "');"),
                x.Button().Text("新增").OnClientClick("App.Grid.OnModuleOperation(this,'" + Url.Action("Create") + "',{ShowOnly:true});"),
                x.Button().Text("修改").Icon(Icon.ApplicationFormEdit).OnClientClick("App.Grid.OnModuleOperation(this,'" + Url.Action("Edit") + "');"),
                x.Button().Text("删除").Icon(Icon.Delete).OnClientClick("App.Grid.OnModuleOperation(this,'" + Url.Action("Delete") + "',{IsAjax:true});"),
                x.Button().Text("权限").DirectClickAction("ListForUserGroup", "Permission")
                    .DirectEvents(de =>
                    {
                        de.Click.ExtraParams.Add(new Parameter("owner", "userGroup"));
                        de.Click.ExtraParams.Add(new Parameter("userGroupId", "this.up('grid').getSelectionModel().getSelection()[0].getData().Id", ParameterMode.Raw));
                        de.Click.ExtraParams.Add(new Parameter("ownerId", "this.up('grid').getSelectionModel().getSelection()[0].getData().Id", ParameterMode.Raw));
                    }),
                new ToolbarFill(),
                x.TextField().Width(300).FieldLabel("搜索").LabelWidth(50)
                    .Triggers(
                        x.FieldTrigger().Icon(TriggerIcon.Clear).HideTrigger(true),
                        x.FieldTrigger().Icon(TriggerIcon.Search)
                    )
                        .Listeners(ls => { ls.TriggerClick.Fn = "App.Main.searchFieldTriggerClick"; })
                ))
            .Store(x.StoreForModel()
                .Proxy(x.AjaxProxy().Url(Url.Action("GetPaged")).Reader(x.JsonReader().RootProperty("data")))
                .RemoteSort(true)
                .PageSize(20)
                .SorterFor(Model, m => m.Id, Ext.Net.SortDirection.DESC))
            .SelectionModel(x.CheckboxSelectionModel())
            .ColumnModel(
                x.RowNumbererColumn().Align(ColumnAlign.End).Width(60),
                x.Column().DataIndex(Model, m => m.Title).Text("名称").Width(200),
                x.ColumnFor(m => m.Remark),
                x.ColumnFor( m => m.CheckInTime),
                x.DateColumn().DataIndex(Model, m => m.ModifiTime).Text("修改时间").Width(130).Format("yyyy-MM-dd"),
                        x.ColumnFor( m => m.ModifiedUserName)
            )
            .BottomBar(x.PagingToolbar().ItemsFromPartial("~/Views/Shared/_PagingToolbarPartial.cshtml"))
            .EmptyText("无数据。")
            .View(Html.X().GridView().StripeRows(true).TrackOver(true))
      
      )